<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>
    <link href="${ctx}/lib/plugins/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <style type="text/css">
    	table.privilegeTable {
    		width: 100%;
    		border-collapse: collapse;
    		border: 1px solid #ccc;
    	}
    	div.ztreePanel {
    		max-height: 450px;
    		min-height: 390px;
    		overflow: auto;
    	}
    	div.ztree {
    		margin: 20px;
    	}
    	.leftTd {
    		vertical-align: top;
    	}
    	.rightTd {
    		width: 50%;
    		height: 100%;
    		vertical-align: top;
    		border-left: 1px solid #ccc;
    	}
    	
    	div.rightTitleDiv {
    		font-size: 20px;
    		margin: 10px 0px 20px 0px;
    		padding: 10px 20px;
    		border-bottom: 1px solid #ccc;
    	}
    	
    	div.rightTextDiv {
    		margin: 10px 0px;
    		padding: 5px 20px;
    	}
    </style>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code='message.lable.miMaXiuGai'/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code='message.lable.first'/></a></li>
            <li class="active"><a href="#"><spring:message code='message.lable.miMaXiuGai'/></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success ">
            <form id="form" class="form-horizontal" action="changePassword.html" method="post">
            	<input type="password" style="display:none">
                <div class="box-body" style="background:url(${ctx}/lib/img/checkpassword.png);background-repeat: no-repeat;background-position: 115px 65px ">
                    <div class="form-group form-group-xs" style="margin-left:200px;margin-top:40px">
                        <label for="password" class="col-sm-2 text-right"><spring:message code='message.lable.dangQianMiMa'/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-5 text-left">
                            <input class="form-control" id="password" name="password" placeholder="<spring:message code='message.lable.dangQianMiMa'/>" type="password" maxlength="127">
                        </div>
                    </div>
                    <div class="form-group form-group-xs" style="margin-left:200px">
                        <label for="newpassword" class="col-sm-2 text-right"><spring:message code='message.lable.newPWD'/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-5 text-left">
                            <input class="form-control" id="newpassword" name="newpassword" placeholder="<spring:message code='message.lable.newPWD'/>" type="password" maxlength="127">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs" style="margin-left:200px">
                        <label for="passwordRepeat" class="col-sm-2 text-right"><spring:message code='message.lable.confirmPWD'/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-5 text-left">
                            <input class="form-control" id="passwordRepeat" name="passwordRepeat" placeholder="<spring:message code='message.lable.confirmPWD'/>" type="password" maxlength="127">
                        </div>
                    </div>
                    <div style="height:20px"></div>
                     <div class="form-group form-group-xs">
                          <label for="newpassword" class="col-sm-3 text-right"><i class="fa fa-exclamation-circle fa-lg" style="color:#dd4b39;"></i>&nbsp;<span style="color:#dd4b39;font-weight:600"><spring:message code="message.lable.tiShi" /><spring:message code="message.yanZheng.maoHao"/></span></label>					        
						    <div class="col-sm-7 text-left" style="color:#dd4b39">
						         <spring:message code="message.lable.PWDhint" />
						    </div>
                    </div>
                </div>
                <div class="box-footer text-center">
                    <ms:btn url="/sysPassWordEdit/changePassword.html"><button type="button" class="btn btn-success btn-sm" onclick="submitPassword();"><spring:message code="message.button.saveSpacing"/></button></ms:btn>
                </div>
            </form>
        </div>
    </section>
    
    <%@ include file="/WEB-INF/component/commonJS.jsp" %>
    <script src="${ctx}/lib/plugins/zTree_v3/js/jquery.ztree.all-3.5.min.js"></script>
    
    <script type="text/javascript">
    	function submitPassword() {
    		//	var parn = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{6,12}$/;
		    var parn =new RegExp("^[0-9]*$");
			var password = $.trim($("#password").val());
    		if (password == null || password == "") {
    			$.HN.message.alert("<spring:message code='message.HN.nowPWD'/>", "", "warn");
    			return false;
    		}
			
    		var newpassword = $.trim($("#newpassword").val());
			if (newpassword == null || newpassword == "") {
				$.HN.message.alert("<spring:message code='message.HN.noPWD'/>", "", "warn");
				return;
			}
			if(newpassword.length != 6){
				$.HN.message.alert("<spring:message code='message.HN.PWDlengthDengYu6'/><spring:message code="message.yanZheng.ganTanHao"/>", "", "warn");
				return;
			}
	/* 		if(newpassword.length > 12){
				$.HN.message.alert("<spring:message code='message.HN.PWDlengthDaYu12'/>", "", "warn");
				return;
			} */
			if(!(parn.test(newpassword))){
				 $.HN.message.alert("<spring:message code='message.lable.PWDhint'/>", "", "warn");
		         return ;
			}
			
			
			var passwordRepeat = $.trim($("#passwordRepeat").val());
			if (passwordRepeat == null || passwordRepeat == "") {
				$.HN.message.alert("<spring:message code='message.HN.noConfirmPWD'/>", "", "warn");
				return;
			}
			
			if (newpassword != passwordRepeat) {
				$.HN.message.alert("<spring:message code='message.HN.notSamePWD'/>", "", "warn");
				return;
			} 

	    	  $.HN.message.confirm("<spring:message code='message.HN.alert.queDingTiJiaoMa'/>", '', '').on(function (e) {
	              if (e) {
	            		$.post("${ctx}/sysPassWordEdit/changePassword.html", {
	            			"password" : password,
	            			"newpassword" : newpassword
	            		}, function(result) {
	            			if (result.success) {
	            				$("#closeChangePasswordDialog").click();
	            				$.HN.message.alert("<spring:message code='message.HN.alert.success'/>", "", "success");
	            				//  setTimeout("count()", 500) 
	            			} else {
	            				$.HN.message.alert(result.msg 
	            						|| "<spring:message code='message.HN.alert.fail'/>", "", "error");
	            			}
	            		}, "json");
	    		}
	       	  });
    	}
    	function count(){
			 
       }
    </script>
    
</body>
</html>
